﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using BYSJ.BLL;
using BYSJ.IBLL;
using BYSJ.Model;

namespace BYSJ.Web.Controllers
{
    //注册方法
    public class CreateAccountController : Controller
    {
        //
        // GET: /CreateAccount/
        IUserSetService UserServic = null;
        public CreateAccountController()
        {
            UserServic = new UserSetService();
        }

        [HttpGet]
        public ActionResult CreateAccount()
        {
            return View();
        }
        [HttpPost]
        public string CreatePostAccount(UserSet user)
        {
            if (UserServic.LoadEntities(u => u.Name == user.Name).ToList().Count() >= 1)
            {
                return "账号已经存在，请重新注册！！";
            }
            else
            {
                try
                {
                    user.ImagePsth = "http://cnkifile.b0.upaiyun.com/bysjdefort/touxiang.jpg";
                    user.CreatTime = DateTime.Now;
                    user.uptime = DateTime.Now;
                    UserServic.Add(user);
                    return "注册成功";
                }
                catch
                {
                    return "注册失败";
                }
            }
        }

    }
}
